package ar.edu.itba.it.paw.web;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


import ar.edu.itba.it.paw.domain.Product;
import ar.edu.itba.it.paw.domain.User;
import ar.edu.itba.it.paw.services.ProductServices;
import ar.edu.itba.it.paw.services.impl.ProductServicesImpl;

@SuppressWarnings("serial")
public class EditProd extends HttpServlet {
	
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
		
		HttpSession session = req.getSession();
		User user = (User) session.getAttribute("usuario");
		
		ProductServices prod_serv = ProductServicesImpl.getInstance();
		List<Product> prod_list = new ArrayList<Product>();
		
		prod_list = prod_serv.getUserProducts(user);
		req.setAttribute("products", prod_list);
		req.getRequestDispatcher("/WEB-INF/jsp/editProduct.jsp").forward(req, resp);
	}
}
